# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=gnome-latex
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
replaces=("${MINGW_PACKAGE_PREFIX}-latexila")
pkgver=3.38.0
pkgrel=1
arch=('any')
pkgdesc="LaTeX editor designed for the GNOME desktop (mingw-w64)"
options=(strip staticlibs)
depends=("${MINGW_PACKAGE_PREFIX}-gsettings-desktop-schemas"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-gtksourceview4"
         "${MINGW_PACKAGE_PREFIX}-gspell"
         "${MINGW_PACKAGE_PREFIX}-tepl5"
         "${MINGW_PACKAGE_PREFIX}-libgee")
makedepends=("itstool"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
license=("GPL 3")
url="https://www.gnome.org"
install=${_realname}-${CARCH}.install
# TODO: update and re-apply 001-win.patch (ideally by contributing upstream).
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz)
sha256sums=('a82a9fc6f056929ea18d6dffd121e71b2c21768808c86ef1f34da0f86e220d77')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  autoreconf -sf -I m4
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --enable-introspection \
    --disable-dconf-migration

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
